package cn.skynethome.redisx.Test;

import cn.skynethome.redisx.RedisSharedMasterSlaveSentinelUtil;

public class TestRedisReadTimes
{
    public static volatile int j = 0;
    public static void main(String[] args) throws InterruptedException
    {
        RedisSharedMasterSlaveSentinelUtil.setString("aaaabbbb", "fsdfsdfasdgdfgdsfgdgfd");

        for (int i = 0; i < 3500; i++)
        {
            new TimeRedis().start();
        }

    }
}

class TimeRedis extends Thread
{
    @Override
    public void run()
    {
        int i=20;
        while(true)
        {
//            try
//            {
//                Thread.sleep(200);
//            }
//            catch (InterruptedException e)
//            {
//                // TODO Auto-generated catch block
//                e.printStackTrace();
//            }
            
            long start = System.currentTimeMillis();
            String str = RedisSharedMasterSlaveSentinelUtil.getString("aaaabbbb");
            long end = System.currentTimeMillis();
            long time = end - start;
            System.out.println("Connection:"+RedisSharedMasterSlaveSentinelUtil.getActiveConnections()+" ***** "+TestRedisReadTimes.j+"==="+this.getId()+"="+(time)+"ms");
            
            if(i<=0)
            {
                break;
            }
            if(time>=100)
            {
                TestRedisReadTimes.j++;
            }
            
            i--;
        }
      
       
    }
}